package composite;

import java.util.ArrayList;
import java.util.List;

public class College extends OrganizationComponent{

    List<OrganizationComponent> organizationComponents = new ArrayList<>();

    public College(String name, String des) {
        super(name, des);
    }

    @Override
    public void add(OrganizationComponent organizationComponent) {
        organizationComponents.add(organizationComponent);
    }

    @Override
    public void remove(OrganizationComponent organizationComponent) {
        organizationComponents.remove(organizationComponent);
    }

    @Override
    public void print() {
        //输出college名字
        System.out.println("-----------"+ super.getName() + "-----");
        //遍历college对象中的department集合
        for (OrganizationComponent organizationComponent : organizationComponents){
            //执行department中的输出方法
            organizationComponent.print();
        }
    }

}
